package com.lavender.annotation;

import com.lavender.annotation._import.ImportTest;
import org.springframework.beans.BeansException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author: zhu.chen
 * @date: 2020/12/5
 * @version: v1.0.0
 */
@EnableAsync
@SpringBootApplication
public class LavenderAnnotationApplication implements ApplicationContextAware {

    public static void main(String[] args) {
        SpringApplication.run(LavenderAnnotationApplication.class, args);
    }

    private ApplicationContext applicationContext;

    /**
     * 测试@import注解
     * @return
     */
    @Bean
    public CommandLineRunner _ImportCommandLineRunner() {
        return (args) -> {
            System.out.println("ImportTest : " + applicationContext.getBean(ImportTest.class));
        };
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

}
